// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <gtest/gtest.h>

#include <pollux/dwio/dwrf/reader/stream_labels.h>

using namespace ::testing;
using kumo::pollux::memory::AllocationPool;
using namespace kumo::pollux::dwrf;

class StreamLabelsTest : public testing::Test {
 protected:
  static void SetUpTestCase() {
    kumo::pollux::memory::MemoryManager::testingSetInstance({});
  }
};

TEST_F(StreamLabelsTest, E2E) {
  auto pool = kumo::pollux::memory::memoryManager()->addLeafPool();
  AllocationPool allocationPool(pool.get());
  StreamLabels root(allocationPool);
  auto c0 = root.append("c0");
  auto c1 = root.append("c1");
  auto c0_f0 = c0.append("f0");
  auto c1_f0 = c1.append("f0");
  EXPECT_EQ(root.label(), "/");
  EXPECT_EQ(c0.label(), "/c0");
  EXPECT_EQ(c1.label(), "/c1");
  EXPECT_EQ(c0_f0.label(), "/c0/f0");
  EXPECT_EQ(c1_f0.label(), "/c1/f0");
}
